<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<head>
    <title>完整demo</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <script src="${ctx}/js/jquery-1.11.0.min.js"></script>
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css">
    <script>
        var ctx = "${ctx}";
    </script>
    <style type="text/css">
        div{
            width:100%;
        }
    </style>
</head>
<body>


<div style="width: 1024px;height: 500px;margin: auto">

    <%--表单--%>
    <div>



        <div class="layui-form-item" style="margin-top:2%">



            <label class="layui-form-label">奖品</label>
            <div class="layui-input-inline">

            <select name="type" id="prizeid" class="layui-input" style="width: 200px">
                <option value="1">30元话费(耗费30张好人卡)</option>
            </select>
            </div>



            <a class="layui-btn layui-btn-primary" href="javascript:js_submit();" style="margin-left:150px ">确认兑换</a>

        </div>


        </div>

        <script type="text/javascript">

            //实例化编辑器
            //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
            //var ue = UE.getEditor('editor');

            function js_submit() {
                var userId =${tbUserNow.id};
                var prizeid = $('#prizeid option:selected').val();
                var money =30;
                $.ajax({
                    type: 'post',
                    url: ctx + "/cashrewards",
                    cache: false,
                    data: {userId,prizeid,money},
                    dataType: '',
                    success: function (data) {
                        if (data.code==0) {
                            alert("成功发起兑换,等待管理员发货");
                        }else {
                            alert("发起兑换失败");
                        }
                    },
                    error: function (data) {
                        alert("error");
                    }
                });
            }
        ;

        </script>
</body>
</html>